<!doctype html>
<html class="no-js">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta name="viewport"
		  content="width=device-width, initial-scale=1">
	<title>结算页面</title>

	<!-- Set render engine for 360 browser -->
	<meta name="renderer" content="webkit">

	<!-- No Baidu Siteapp-->
	<meta http-equiv="Cache-Control" content="no-siteapp"/>

	<link rel="icon" type="image/png" href="i/favicon.png">

	<!-- Add to homescreen for Chrome on Android -->
	<meta name="mobile-web-app-capable" content="yes">
	<link rel="icon" sizes="192x192" href="i/app-icon72x72@2x.png">

	<!-- Add to homescreen for Safari on iOS -->
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-title" content="Amaze UI"/>
	<link rel="apple-touch-icon-precomposed" href="i/app-icon72x72@2x.png">

	<!-- Tile icon for Win8 (144x144 + tile color) -->
	<meta name="msapplication-TileImage" content="i/app-icon72x72@2x.png">
	<meta name="msapplication-TileColor" content="#0e90d2">

	<link rel="stylesheet" href="__TMPL__/public/shop/css/amazeui.css">
	<link rel="stylesheet" href="__TMPL__/public/shop/css/jiesuan.css">
	<style>
		.alert-success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6;}
	</style>
</head>
<body onload="javascript:return require();">
<div class="alert"></div>
<section class="wapper">
	<div class="am-g am-padding am-posre">
		<!--左边内容-->
		<input type="hidden" id="order" value="{$date.orderid}">
		<input type="hidden" id="detail_id" value="{$date.id}">
		<section class="am-u-sm-6 am-u-md-6 am-u-lg-6" >
			<div class="">
				<form class="am-form am-form-horizontal">
					<div class="am-form-group">
						<label class="am-u-sm-2 am-form-label">小计：</label>
						<div class="am-u-sm-10">
							<input type="text" readonly="readonly" class="all_money" value="{$date.total}">
						</div>
					</div>
					<div class="am-form-group">
						<label class="am-u-sm-2 am-form-label">改价：</label>
						<div class="am-u-sm-10">
							<input type="text" class="cash" id="cash" readonly="readonly" value="" style="color:#D10612;">
						</div>
					</div>
					<div class="am-form-group keybord-box">
						<table class="am-table am-text-center">
							<tbody>
							<tr>
								<td><label class="number" id="7">7</label></td>
								<td><label class="number" id="8">8</label></td>
								<td><label class="number" id="9">9</label></td>
								<td><label class="price am-btn-danger" id="100">￥100</label></td>
								<td><label class="delete"><em class="am-icon-mail-reply"></em></label></td>
							</tr>
							<tr>
								<td><label class="number" id="4">4</label></td>
								<td><label class="number" id="5">5</label></td>
								<td><label class="number" id="6">6</label></td>
								<td><label class="price am-btn-danger" id="50">￥50</label></td>
								<td><label class="am-normal empty">清空</label></td>
							</tr>
							<tr>
								<td><label class="number" id="1">1</label></td>
								<td><label class="number" id="2">2</label></td>
								<td><label class="number" id="3">3</label></td>
								<td><label class="price am-btn-danger" id="20">￥20</label></td>
								<td rowspan="2"><label class="submit am-normal">确定</label></td>
							</tr>
							<tr>
								<td><label class="number" id="00">00</label></td>
								<td><label class="number" id="0">0</label></td>
								<td><label class="number" id="point">.</label></td>
								<td><label class="price am-btn-danger" id="10">￥10</label></td>
							</tr>
							</tbody>
						</table>
					</div>

				</form>
			</div>
		</section>
	</div>

</section>

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="__TMPL__/public/shop/js/jquery.js"></script>
<script src="__STATIC__/js/layer/layer.js"></script>
<!--<![endif]-->
<!--[if lte IE 8 ]>
<script src="__TMPL__/public/shop/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->
<script src="__TMPL__/public/shop/js/amazeui.min.js"></script>
<script language="javascript" src="__TMPL__/public/assets/dayin/LodopFuncs.js"></script>
<script>
    $(function(){
        $('.am-table label.number').click(function(){
            var old_text = $('.cash').val();
            var text = $(this).attr('id');
            if(text == "point"){
                if(old_text.indexOf('.') == -1){
                    var new_text = old_text + ".";
                }else{
                    var new_text = old_text;
                }
            }else{
                var new_text = old_text + text;
            }
            $('.cash').val(new_text);
        })

        //选择金额
        $('.am-table label.price').click(function(){
            $('.cash').val($(this).attr('id'));
        })

        //删除
        $('.am-table label.delete').click(function(){
            var old_text = $('.cash').val();
            old_text = old_text.substring(0, old_text.length-1);
            $('.cash').val(old_text);
        })

        //清空
        $('.am-table label.empty').click(function(){
            $('.cash').val("");
        })
        //确定
        $('.am-table label.submit').click(function(){
            var cash=$('#cash').val();
            var orderid=$('#order').val();
            var detail=$('#detail_id').val();
            var index = parent.layer.getFrameIndex(window.name);
            $.post("{:url('menu/detailpost')}",{orderid:orderid,gaijia:cash,detail_id:detail}, function (date) {
                if(date.msg.data != null)
                {
                    parent.$('.orderid').html(orderid + '<input type="hidden" id="orderid" value="' + orderid + '">');
                    var data = date.msg.data;
                    var src = '';
                    var pay = date.msg.pay;
                    parent.$('.num').html(pay.num);
                    parent.$('.all').html(pay.all_money);
                    parent.$('#vip').val(pay.vip);
                    parent.$('.orderid').html('<input class="am-text-right" type="text" value="'+pay.orderid+'" style="background: transparent;border:none;">'+'<input type="hidden" id="orderid" value="' + pay.orderid + '">');
                    $.each(data, function (k, val) {
                        var k=k+1;
                        src += '<dl class="am-padding-top-xs am-padding-bottom-xs am-padding-left-sm ">' +
                            '<dt class="dt-h font-z">' +
                            k+
                            val.g_goodsname + '(' + val.format + ')' +
                            '</dt>'+
                            '<div class="am-input-group am-fr">'+
                            '<span class="am-input-group-label minus"  onclick="javascript:minus(this)">-'+
                            '</span>'+
                            '<input type="hidden"  class="am-form-field detail_id" value="'+
                            val.id+
                            '">'+
                            '<input type="hidden"  class="am-form-field stemeals" value="'+
                            val.stemeal+
                            '">'+
                            '<input type="hidden"  class="am-form-field nature" value="'+
                            val.nature+
                            '">'+
                            '<input type="text" readonly="readonly" class="am-form-field" value="'+
                            val.count+
                            '">'+
                            '<span class="am-input-group-label add"  onclick="javascript:add(this)">+'+
                            '</span>'+
                            '</div>'+
                            '<input type="hidden"  class="am-form-field ordid" value="'+
                            val.orderid+
                            '">'+
                            '<dd>'+
                            '<div class="am-u-md-6 am-u-lg-6 am-padding-left-0 left-w ">'+
                            '<input type="hidden"  class="am-form-field detail_id" value="'+
                            val.id+
                            '">'+
                            '<div class="am-link-muted am-text-xs font-z">单价：￥'+
                            val.money +
                            '</div>'+
                            '<div class="am-text-danger am-text-xs font-z ">小计：￥<span class="ipt1" style="display: inline;cursor:pointer;color:green;">'+
                            val.total +'</span>'+
                            '<input class="ipt2" style="display:none;width:100%;border:1px solid red;width:40px;" maxlength="10"/><input class="ipt3" type="hidden" value="'+val.total+'"/>'+
                            '</div>'+
                            '</div>'+
                            '<div class="am-u-md-6 am-u-lg-6 am-padding-right-0">'+
                            '</div>'+
                            '<div class="clear"></div>'+
                            '<div class="am-u-md-6 am-u-lg-6 am-padding-left-0 left-w ss">'+
                            '<div class="flo-l font-z wendu">'+
                            '<input type="hidden"  class="am-form-field detail_id" value="'+
                            val.id+
                            '">'+
                            '<input type="hidden"  class="am-form-field goodid" value="'+
                            val.goodsid+
                            '">'+
                            '<a class="am-btn am-btn-warning am-radius am-margin-right-sm nature" herf="#">口味('+
                            val.naturename+
                            ')</a>'+
                            '<a class="am-btn am-btn-warning am-radius am-margin-right-sm edit" herf="#">改价'+
                            '</a>'+
                            '</div>'+
                            '</div>'+
                            '</dd>' +
                            '</dl>'
                        parent.$('#cart').html(src);
                    });
                    parent.layer.close(index); //执行关闭
                }else{
                    alert('添加失败');
                }
        })
		})
    })
</script>
</body>
</html>